<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
   
</head>

<body>
    <select >
        <option value = "red">红色</option>
        <option value = "blue">蓝色</option>
        <option value = "pink">粉色</option>
        <option value = "green">绿色</option>
    </select>
    <div class="content">
        当选中select上的标签 将content中的内容设置为指定的颜色
    </div>
    <script>
        // 当选中select上的标签 将content中的内容设置为指定的颜色
        
        
        // var cont = document.querySelector(".content");
        // var selEle = document.getElementById("sel");
        // cont.style.color = selEle.value =="红色"?"red":"blue";
        // selEle.onchange =() =>{
        //     cont.style.color = selEle.value =="红色"?"red":"blue";
        // }
        
        document.querySelector("select").onchange = function(){
            document.querySelector(".content").style.color = this.value;
        }
        

    </script>
</body>

</html>